package com.lianxueda.drawing.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lianxueda.drawing.domain.dto.ClassFormDTO;
import com.lianxueda.drawing.domain.dto.ClassQueryDTO;
import com.lianxueda.drawing.domain.pojo.Classes;
import com.lianxueda.drawing.domain.vo.ClassVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClassMapper extends BaseMapper<Classes> {

    
    



    IPage<Classes> selectClassesWithTeacherName(IPage<Classes> page, @Param("ew")  LambdaQueryWrapper<Classes> qw);
    @Select("select id from teachers where name=#{teacherName}")
    Integer selectTeacherIdByName(String teacherName);

    List<Classes> findByPage(ClassQueryDTO classQueryDTO);

    @Select("SELECT c.name FROM classes c " +
            "JOIN class_courses cc ON c.id = cc.class_id " +
            "WHERE cc.course_id = #{id}")
    String selectClassNameByCourseId(Integer id);
    @Select("SELECT id FROM classes WHERE name = #{className}")
    Integer selectClassIdByName(String className);

    void updateByClassId(@Param("classForm") ClassFormDTO classForm);
}
